package com.love_weinuo.ui.activity;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.love_weinuo.R;
import com.love_weinuo.databinding.ActivityNearLandBinding;
import com.love_weinuo.ui.BaseActivity;
import com.love_weinuo.ui.adapter.NearLandAdapter;
import com.love_weinuo.ui.adapter.OnItemClickListener;
import com.love_weinuo.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2019/3/2.
 */

public class NearLandActivity extends BaseActivity {

    ActivityNearLandBinding binding;
    List<String> strs = new ArrayList<>();
    NearLandAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_near_land);
        binding.setActivity(this);
        initView();
    }

    private void initView() {
        add(this);
        setBack();
        setTitleText("附近要拼地块");
        setRightText("添加");

        strs.add("潇洒哥");
        strs.add("潇洒哥");
        strs.add("潇洒哥");
        strs.add("潇洒哥");
        strs.add("潇洒哥");

        adapter = new NearLandAdapter(this, strs);
        binding.recycler.setLayoutManager(new LinearLayoutManager(this));
        binding.recycler.setAdapter(adapter);
        adapter.setOnItemClickLitener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                ToastUtil.showToast("选择附近第" + position + "块土地");
            }

            @Override
            public void onItemLongClick(View view, int position) {

            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.rightText:
                ToastUtil.showToast("添加土地");
                break;
                default:
        }
    }
}
